/*--------------------------------------------------------------------------------*/
#ifndef __GRAPHIC_SHADER_PROGRAM__
#define __GRAPHIC_SHADER_PROGRAM__
/*--------------------------------------------------------------------------------*/
#include "primitives.h"
#include "object.h"
#include "util.h"
#include <GL/gl.h>
#include <GL/glext.h>
#include "text.h"
#include "graphic_shader.h"
/*--------------------------------------------------------------------------------*/
class GRAPHIC_SHADER_PROGRAM : public OBJECT
{

	// -- PUBLIC

public:

    DECLARE_REF( GRAPHIC_SHADER_PROGRAM );

    // .. CONSTRUCTORS

    GRAPHIC_SHADER_PROGRAM() :
    	OBJECT(),
    	Id( 0 )
    {

    }

    ~GRAPHIC_SHADER_PROGRAM()
    {
    	if( Id )
    	{
    		glDeleteProgram( Id );
    	}
    }

    // .. METHODS

    VOID Initialize( const GRAPHIC_SHADER vertex_shader,  const GRAPHIC_SHADER pixel_shader  );

    VOID AddShader( const GRAPHIC_SHADER shader );

    VOID Enable();

    VOID Disable();

    const GLuint & GetId() const
    {
    	return Id;
    }

    // .. EXTENSIONS METHODS

    static PFNGLCREATEPROGRAMPROC
		glCreateProgram;
    static PFNGLDELETEPROGRAMPROC
		glDeleteProgram;
	static PFNGLATTACHSHADERPROC
		glAttachShader;
	static PFNGLDETACHSHADERPROC
		glDetachShader;
	static PFNGLLINKPROGRAMPROC
		glLinkProgram;
	static PFNGLGETPROGRAMIVPROC
		glGetProgramiv;
	static PFNGLGETPROGRAMINFOLOGPROC
		glGetProgramInfoLog;
	static PFNGLUSEPROGRAMPROC
		glUseProgram;

    // -- PRIVATE

private :

	// .. METHODS

    BOOL IsLinked() const;
    const TEXT GetInfoLog() const;

    // .. ATTRIBUTES

    GLuint
		Id;
};
/*--------------------------------------------------------------------------------*/
#endif
